#ifndef SIMULATORPARAMETERS_H_
#define SIMULATORPARAMETERS_H_

#include "auxiliar.h"

struct BdryConditionType
{
	string type;		// dirichlet or neumann
	double val;		// pointer to prescribed value
};

typedef map<int,BdryConditionType*> MapFlag;
typedef map<int,BdryConditionType*>::iterator MapFlagIter;


struct RockProperties
{
	double porosity;
	double *K;
};

typedef map<int,RockProperties*> MapRockProperties;
typedef map<int,RockProperties*>::iterator MIter_RockProperties;


class SimulatorParameters
{
public:
	
	SimulatorParameters();
	~SimulatorParameters();
	
	void loadParameters();
	double getBC_Value(const int &flag);	
	bool finishSimulation(double t);	
	bool isNodeFree(const int &flag);	
	void readRockProperties(ifstream &fid);
	int meshDimension() const;
	
	// numeic parameters
	// -------------------------------------------------------------------------
	double CFL() const;
	bool isHigherOrder() const;	// order approximation
	int numTimeStep() const;
	int totalTimeSimulation() const;
	int EF() const;	// (export frequency):	export data to vtk format every n time steps
	int RF() const;	// (restart frequency):	run restart every n time steps

	// solver settings parameters
	// -------------------------------------------------------------------------
	double abstol() const;
	double rtol() const;
	double stol() const;
	int maxit() const;
	int maxf() const;

	// physical parameters
	// -------------------------------------------------------------------------
	double getPorosity(const int &dom);
	double oilDensity() const;
	double waterDensity() const;
	double oilViscosity() const;
	double waterViscosity() const;
	const double* getPermeability(const int &dom);
	
	// initial conditions
	double Sw_initial() const;
	
	bool hasNodeWell(const int &flag);

	void printParameters();
	
private:
	
	void setPositionToRead(ifstream &fid, string str);	
	void mapFlag(ifstream &fid, string whatmap);	
	
	
	MapRockProperties mapRockProp;	
	MapFlag mapBC;
	MapFlag mapSaturation;
	
	int _meshdim;
	
	// numeric parameters
	// -------------------------------------------------------------------------
	double _CFL;
	int _AppOrder;
	int _NOTS;
	int _TTOS;
	int _EF;	// (export frequency):	export data to vtk format every n time steps
	int _RF;	// (restart frequency):	run restart every n time steps
	unsigned int TimeStepCounter;
	
	// -------------------------------------------------------------------------
	double _abstol;
	double _rtol;
	double _stol;
	int _maxit;
	int _maxf;
	
	// physical parameters
	// -------------------------------------------------------------------------
	double _phi;
	double _oil_density;
	double _water_density;
	double _oil_viscosity;
	double _water_viscosity;
	
	// initial conditions parameters
	double _Sw_initial;
	
	bool well;	// inside isNodeFree() well is set to inform if node has a well or not
};

#endif /*SimulatorParameters_H_*/
